using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.IO;namespace 体育彩票选号器{ public partial class FrmKai : Form { private int order = 0;//选号的组号 int[] arrRedBall = new int[6]; int[] arrRedBall2 = new int[6]; int Irednum = 0, Ibluenum = 0; public FrmKai() { InitializeComponent(); } class PickDevice { private Random random; private Calendar myCalendar; internal Calendar MyCalendar { get { this.myCalendar.Year = DateTime.Now.Year.ToString(); this.myCalendar.Month = DateTime.Now.Month.ToString("00"); this.myCalendar.Day = DateTime.Now.Day.ToString("00"); this.myCalendar.Time = DateTime.Now.ToLongTimeString(); this.myCalendar.Week = WeekToChineseWeek(DateTime.Now.DayOfWeek.ToString()); return myCalendar; } //set { myCalendar = value; } } /// <summary> /// 选中的号码 /// </summary> private List<string> selectedNum; public List<string> SelectedNum { get { return selectedNum; } set { selectedNum = value; } } public PickDevice() { random = new Random(); myCalendar = new Calendar(); selectedNum = new List<string>(); } /// <summary> /// 生成10以内随机号码 /// </summary> /// <returns></returns> public int[] CreateNum() { int[] Rnum = new int[6]; for (int i = 0; i < 6; i ) { int n = random.Next(1, 33); if (!Rnum.Contains(n)) Rnum[i] = n; else i--; } Rnum = Rnum.OrderBy(x => x).ToArray(); return Rnum; } public object getBlueNum(int[] Bnum) { // Random random = new Random(); int blueNum = random.Next(1, 16); if (Bnum.Contains(blueNum)) getBlueNum(Bnum); return blueNum; } public void ExportToTxt(string path) { using (FileStream fs = new FileStream(path, FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs)) { foreach (string s in SelectedNum) { sw.WriteLine(s); } } } } /// <summary> /// 将英文日期转换为中文 /// </summary> /// <param name="week"></param> /// <returns></returns> public string WeekToChineseWeek(string week) { switch (week) { case "Monday": return "一"; //break; case "Tuesday": return "二"; //break; case "Wednesday": return "三"; //break; case "Thursday": return "四"; //break; case "Friday": return "五"; //break; case "Saturday": return "六"; //break; case "Sunday": return "日"; //break; default: return "日"; //break; } } } private void Trmi1_Tick(object sender, EventArgs e) { arrRedBall2 = FrmMain.pickDevice.CreateNum(); this.lblNum8.Text = arrRedBall2[0].ToString(); this.lblNum9.Text = arrRedBall2[1].ToString(); this.lblNum10.Text = arrRedBall2[2].ToString(); this.lblNum11.Text = arrRedBall2[3].ToString(); this.lblNum12.Text = arrRedBall2[4].ToString(); this.lblNum13.Text = arrRedBall2[5].ToString(); int[] Bnum = FrmMain.pickDevice.CreateNum(); this.lblNum14.Text = FrmMain.pickDevice.getBlueNum(Bnum).ToString(); } private void button1_Click(object sender, EventArgs e) { int i, j; for (i = 0; i < 6; i ) { for (j = 0; j < 6; j ) if (arrRedBall[i] == arrRedBall2[j]) { Irednum ;//记录红球相同的个数 } } if (Convert.ToString(FrmMain.Blueball) == lblNum14.Text) Ibluenum ; if (Ibluenum > 0) { if (Irednum == 6) { MessageBox.Show("恭喜你中了一等奖"); } else if (Irednum == 5) { MessageBox.Show("恭喜你中了二等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } else if (Irednum == 4) { MessageBox.Show("恭喜你中了三等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } else if (Irednum == 3) { MessageBox.Show("恭喜你中了四等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } else if (Irednum == 2) { MessageBox.Show("恭喜你中了五等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } else if (Irednum == 1) { MessageBox.Show("恭喜你中了六等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } else if (Irednum == 0) { MessageBox.Show("恭喜你中了七等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } } else { if (Irednum == 6) { MessageBox.Show("恭喜你中了二等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } else if (Irednum == 5) { MessageBox.Show("恭喜你中了三等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } else if (Irednum == 4) { MessageBox.Show("恭喜你中了四等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } else if (Irednum == 3) { MessageBox.Show("恭喜你中了五等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } else if (Irednum == 2 || Irednum == 1 || Irednum == 0) { MessageBox.Show("很遗憾没中奖哦,再接再厉哦"); } else if (Irednum == 0) { MessageBox.Show("恭喜你中了七等奖" " " "中奖红球个数" Irednum " " "中奖蓝球个数" Ibluenum); } } } private void btnKai_Click(object sender, EventArgs e) { this.Trmi1.Stop(); this.btnKai.Enabled = !this.btnKai.Enabled; string num = ""; num = this.lblNum8.Text; num = " " this.lblNum9.Text; num = " " this.lblNum10.Text; num = " " this.lblNum11.Text; num = " " this.lblNum12.Text; num = " " this.lblNum13.Text; num = " "; num = this.lblNum14.Text; order ; lstNum2.Items.Add("本期大奖是:" " " num); FrmMain.pickDevice.SelectedNum.Add(num); } }}
评论